using System;
using System.Globalization;
using System.Windows.Controls;

namespace Theodorus
{
	public class NonNegativeIntegerRule : ValidationRule
	{
		public override ValidationResult Validate(object value, CultureInfo cultureInfo)
		{
			int val;
			if (Int32.TryParse((string) value, out val))
			{
			    return val < 0
			               ? new ValidationResult(false, "Must be a positive number")
			               :
			                   new ValidationResult(true, null);
			}
			return new ValidationResult(false, "Must be an integer");

		}
	}
}